package com.mygame.xinyue.handler;


import com.mygame.common.component.BaseRoute;
import com.mygame.common.component.RequestPacket;
import com.mygame.common.component.annotation.Route;
import com.mygame.common.component.annotation.Rpc;
import com.mygame.common.msg.CommandEnum;
import com.mygame.common.msg.MessageType;
import com.mygame.common.msg.ServiceEnum;
import com.mygame.db.entity.manager.ArenaManager;
import com.mygame.common.protobuf.ExternalMessage;
import com.mygame.common.protobuf.ExternalMessageUtil;
import com.mygame.common.protobuf.rpcMsg.ConsumeDiamondRequest;
import com.mygame.common.protobuf.rpcMsg.ConsumeDiamondResponse;
import com.mygame.message.rpc.RPCEventContext;
import org.springframework.stereotype.Component;

@Component
@Route(serviceType = ServiceEnum.GAME_LOGIC)
public class RpcHandler implements BaseRoute<RequestPacket> {

    @Override
    public void onReceive(RequestPacket packet) {
        System.out.println("CommonHandler");
    }


    @Rpc(cmd = CommandEnum.RPC_CONSUME_DIAMOND_REQ)
    public void RPC_CONSUME_DIAMOND_REQ(ConsumeDiamondRequest gameMessage, RPCEventContext<ArenaManager> ctx) {
        ConsumeDiamondResponse response = new ConsumeDiamondResponse();
        ExternalMessage res = ExternalMessageUtil.build(CommandEnum.RPC_CONSUME_DIAMOND_RSP, response);
        res.setMessageType(MessageType.RPC_RESPONSE.id);
        ctx.sendRpcResponse(res);
    }

}